home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 41 / Issue 41.iso / pc / PCSoftware / Netscape 6 Official Release / nim.xpi / bin / chrome / aim.jar / content / aim / migrationWizard.js < prev    next >
Encoding:
JavaScript  |  2000-09-13  |  6.8 KB  |  210 lines

  1. /*
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  *
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  *
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  *
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  *   Ben Goodger (30/09/99)
  22.  */ 
  23.  
  24. // The WIZARD of GORE
  25.  
  26. //var profile = Components.classes["@mozilla.org/profile/manager;1"].createInstance();
  27. //profile = profile.QueryInterface(Components.interfaces.nsIProfile); 
  28.  
  29. var migrationScreenName = "";
  30. var migrationPassword = "";
  31. var migrationSource = "";
  32. var migrationScreenNameVec = "";
  33. var migrationScreenNameVecSize = 0;
  34.  
  35. // Navigation Set for pages contained in wizard
  36. var wizardMap = {
  37.   migWiz0_0_0: { previous: null,              next: "migWiz1_0_0",    finish: false },
  38.   migWiz0_0_1: { previous: null,              next: "migWiz2_0_0",    finish: false },
  39.   migWiz1_0_0: { previous: "migWiz0_0_0",              next: null,    finish: true },
  40.   migWiz1_1_0: { previous: "migWiz1_0_0",              next: null,    finish: true },
  41.   migWiz2_0_0: { previous: "migWiz0_0_1",              next: null,    finish: true },
  42.   migWiz2_1_0: { previous: "migWiz3_0_0",              next: null,    finish: true },
  43.   migWiz2_1_1: { previous: "migWiz2_0_0",              next: null,    finish: true },
  44.   migWiz3_0_0: { previous: "migWiz0_0_1",              next: "migWiz2_1_0",    finish: false },
  45.   migWiz4_0_0: { previous: "migWiz0_0_1",              next: null,    finish: true },
  46.   //newProfile1_2: { previous: "newProfile1_1",   next: null,               finish: true },
  47. }
  48.  
  49. // page specific variables
  50. var profName      = "";
  51. var profDir       = "";
  52. var wizardManager = null;
  53.  
  54. // startup procedure
  55. function Startup( startPage, frame_id )
  56. {
  57.   if( frame_id == "" ) {
  58.     dump("Please supply a content_frame ID!");
  59.     return false;
  60.   }
  61.   
  62.   // instantiate the Wizard Manager
  63.   wizardManager                   = new WizardManager( frame_id, null, null, wizardMap );
  64.   wizardManager.URL_PagePrefix    = "chrome://aim/content/";
  65.   wizardManager.URL_PagePostfix   = ".xul";
  66.  
  67.   // set the button handler functions
  68.   wizardManager.SetHandlers( null, null, onFinish, onCancel, null, null );
  69.  
  70.     //determine starting wizard panel  
  71.  
  72.     var firstScreen = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  73.  
  74.  
  75.     if (!firstScreen || firstScreen == '') {
  76.         //first time logging in with no screen name
  77.         startPage='migWiz0_0_1'
  78.  
  79.     }
  80.     
  81.   
  82.   // load the start page
  83.   //dump("calling loadpage...\n");
  84.   //dump("startPage:: " + startPage + "\n");
  85.  
  86.     wizardManager.LoadPage( startPage, false );
  87.   // move to center of screen if no opener, otherwise, to center of opener
  88.   if( window.opener )
  89.     moveToAlertPosition();
  90.   else
  91.     centerWindowOnScreen();
  92. }
  93.  
  94. function onCancel()
  95. {
  96.   if( top.window.opener )
  97.     window.close();
  98.   else { 
  99.     try {
  100.         profile.forgetCurrentProfile();
  101.     }
  102.     catch (ex) {
  103.         dump("failed to forget current profile.\n");
  104.     }
  105.     ExitApp();
  106.   }
  107. }
  108.  
  109. function onFinish(){
  110.       dump("*** IN ONFINISH\n");
  111.       
  112.       var sname = "";
  113.       var pword = "";
  114.       //when I am finished - check which page I finished on then set the parent if necessary
  115.       if(wizardManager.currentPageTag=="migWiz2_0_0" || wizardManager.currentPageTag=="migWiz4_0_0" ){
  116.           //alert(document.frames.length);
  117.           //sname=wizardManager.wizardMap[wizardManager.currentPageTag].inputscreename
  118.           //pword=wizardManager.wizardMap[wizardManager.currentPageTag].inputpassword
  119.           //alert(sname);
  120.           pword = top.frames[0].document.getElementById("inputpassword").value
  121.         if ( wizardManager.currentPageTag=="migWiz4_0_0" ) {
  122.             var list = top.frames[0].document.getElementById("menulistscreenname");
  123.             var selIndex = list.selectedIndex;
  124.             dump( "selIndex is " + selIndex + "\n" );
  125.             if ( selIndex == 0 ) 
  126.                 sname = parent.migrationScreenName;
  127.             else
  128.                 sname = parent.migrationScreenNameVec[ selIndex - 1 ];
  129.         } else
  130.             sname = top.frames[0].document.getElementById("inputscreename").value
  131.  
  132.         dump( "sname is " + sname + "\n" );
  133.         
  134.         //dump("sname:"+ sname+"\n");
  135.         //sname='goog'
  136.         //pword='magog'
  137.       }
  138.       
  139.       if(wizardManager.currentPageTag=="migWiz2_1_0"){
  140.         sname = top.frames[0].document.getElementById("inputscreename").value
  141.           pword = top.frames[0].document.getElementById("inputpassword").value
  142.  
  143.       }
  144.  
  145.     cmdRegisterRemoteScreenNameWiz(wizardManager.currentPageTag,sname,pword);
  146.         aimPrefsManager().SetBoolPref("aim.session.finishedwizard",true, null, true);
  147.     var checkbox = top.frames[0].document.getElementById("migrateScreenNameCheck");
  148.     if ( checkbox && checkbox.checked == false ) {
  149.         aimPrefsManager().SetCharPref("aim.session.migrateBuddyList",sname, null, true);
  150.     }
  151.         
  152.     window.close();
  153.     
  154. }
  155.  
  156.  
  157. /** void ExitApp( void ) ;
  158.  *  - purpose: quits the application properly and finally, stops event loop
  159.  *  - in:  nothing
  160.  *  - out: nothing
  161.  **/               
  162. function ExitApp()
  163. {
  164.   // Need to call this to stop the event loop
  165.   var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
  166.   appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
  167.   appShell.Quit();
  168. }
  169.  
  170. // load string bundle
  171. //var bundle = srGetStrBundle("chrome://communicator/locale/profile/createProfileWizard.properties");
  172.  
  173.  
  174. //set up login screen
  175. function cmdRegisterRemoteScreenNameWiz(panelName,sn,pw) {
  176.     
  177.   if(sn == "")
  178.     sn = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  179.  
  180.   aimPrefsManager().SetCharPref("aim.session.screenname", sn, null, true);
  181.   if(pw != "")
  182.     {
  183.     aimSessionSavePassword(pw);
  184.     aimPrefsManager().SetBoolPref("aim.session.storepassword", true, null, false);
  185.     }
  186.  
  187.   aimPrefsManager().SetBoolPref("aim.session.autologin", false, null, false);
  188.  
  189.     //parent.arguments[0].getElementById('fldScreenName').value = sn;
  190.     //parent.arguments[0].getElementById('fldPassword').value = pw;
  191.     //parent.arguments[0].getElementById('chkSavePassword').checked = false;
  192.     //parent.arguments[0].getElementById('chkSavePassword').disabled = false;
  193.     //parent.arguments[0].getElementById('chkAutoLogin').checked = false;
  194.     
  195.     wizard_AimSession_Register(sn)
  196.     
  197.     top.close()
  198.  
  199.  
  200. }
  201.  
  202.  
  203.  
  204. function wizard_AimSession_Register(screenName)
  205. {
  206.     if(aimSession())
  207.     aimSession().RegisterScreenName(screenName);
  208. }
  209.  
  210.